import "package:flutter/material.dart";

// 滚动菜单列表对象
class ScrollRowTabItem {
  String imgUrl; //菜单图片地址
  String title; //菜单标题
  String? path; //跳转地址
  ScrollRowTabItem({
    required this.imgUrl,
    required this.title,
    this.path,
  });
}

// 水平滚动菜单
class ScrollRowTabWidget extends StatelessWidget {
  final List<ScrollRowTabItem> scrollRowTabList = [
    ScrollRowTabItem(title: '手办雕', imgUrl: "./images/tab_1.jpg"),
    ScrollRowTabItem(title: '漫展演', imgUrl: "./images/tab_2.jpg"),
    ScrollRowTabItem(title: '毛绒玩', imgUrl: "./images/tab_3.jpg"),
    ScrollRowTabItem(title: '谷子', imgUrl: "./images/tab_4.jpg"),
    ScrollRowTabItem(title: '轻小说', imgUrl: "./images/tab_5.jpg"),
    ScrollRowTabItem(title: '众筹', imgUrl: "./images/tab_1.jpg"),
    ScrollRowTabItem(title: '景品', imgUrl: "./images/tab_2.jpg"),
    ScrollRowTabItem(title: 'Q版手', imgUrl: "./images/tab_3.jpg"),
    ScrollRowTabItem(title: '漫画', imgUrl: "./images/tab_4.jpg"),
    ScrollRowTabItem(title: '画集', imgUrl: "./images/tab_5.jpg"),
  ];
  ScrollRowTabWidget({super.key});
  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: const BoxDecoration(color: Colors.transparent),
      width: double.infinity,
      padding: const EdgeInsets.only(top: 6, bottom: 2),
      height: 70,
      child: ListView.builder(
        scrollDirection: Axis.horizontal,
        itemCount: scrollRowTabList.length,
        itemBuilder: (BuildContext context, int index) {
          ScrollRowTabItem item = scrollRowTabList[index];
          double leftEdge = 0;
          double rightEdge = 13;
          if (index == 0) leftEdge = 13;
          return Padding(
            padding: EdgeInsets.only(left: leftEdge, right: rightEdge),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                ClipRRect(
                  borderRadius: BorderRadius.circular(16),
                  child: Image.asset(
                    item.imgUrl,
                    fit: BoxFit.cover,
                    width: 32,
                    height: 32,
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.only(top: 2),
                  child: Text(
                    item.title,
                    style: const TextStyle(
                      color: Colors.black,
                      fontSize: 12,
                    ),
                  ),
                ),
              ],
            ),
          );
        },
      ),
    );
  }
}
